package com.mbengue.corp.artisan.modele;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.Table;

@Entity
@Table(name="client")
@NamedNativeQueries(value = {
    @NamedNativeQuery(name = "trouverClientParNumeroTelephone", query = "select * from client where telephone = ?", resultClass = Client.class),
    @NamedNativeQuery(name = "trouverClientParNom", query = "select * from client where nom = ? or prenom = ?", resultClass = Client.class),
    @NamedNativeQuery(name = "trouverClientParAdresse", query = "select * from client where adresse = ?", resultClass = Client.class),
    @NamedNativeQuery(name = "trouverClientNomEtPrenom", query = "select * from client where nom = ? and prenom = ?", resultClass = Client.class) })
public class Client implements Serializable {
	private static final long serialVersionUID = 6324730461927431204L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="clientId")
	private long clientId;
  @Column(name = "nom", length = 60)
	private String nom;
  @Column(name = "prenom", length = 100)
	private String prenom;
  @Column(name = "telephone", unique = true, length = 15)
	private String telephone;
  @Column(name = "adresse", length = 120)
  private String adresse;
  @Column(name = "zip", length = 5)
  private String codePostal;
  @Column(name = "ville", length = 100)
  private String ville;
  @Column(name = "fullname", length = 161)
  private String fullName;

	public Client() {
	}

	public long getClientId() {
		return clientId;
	}

	public void setClientId(long clientId) {
		this.clientId = clientId;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

  public String getAdresse() {
		return adresse;
	}

  public void setAdresse(String adresse) {
		this.adresse = adresse;
	}

  public String getCodePostal() {
    return codePostal;
  }

  public void setCodePostal(String codePostal) {
    this.codePostal = codePostal;
  }

  public String getVille() {
    return ville;
  }

  public void setVille(String ville) {
    this.ville = ville;
  }

  public String getFullName() {
    return fullName;
  }

  public void setFullName(String fullName) {
    this.fullName = fullName;
  }

  @Override
  public String toString() {
    String cltString = nom + " " + prenom + " tel: " + telephone + " adresse: " + adresse + " " + codePostal + " "
        + ville;
    return cltString;
  }

  public Object[] toArray() {
    Object[] table = { nom.toUpperCase(), prenom, telephone, adresse, codePostal, ville };
    return table;
  }
}
